<?php 
    $categories = View::get('demots_categories'); 
    $demot_category = View::get('demot_category');
    
    $demot_category['id'] = isset($demot_category['id']) ? $demot_category['id'] : '0';
    $demot_category['name'] = isset($demot_category['name']) ? $demot_category['name'] : '';
    $demot_category['img'] = isset($demot_category['img']) ? $demot_category['img'] : '';
    
    $action = View::get('demot_action');

?>

<div class="round half left">
    <div class="round-head">
                <h2>Lista kategorii</h2>                
        </div>

        <div class="round-content">

                <div class="hidden filter-boxes">

                        <form>
                             
                                <div class="filter-item">
                                        <label>Name</label>
                                        <input type="hidden" value=""/>
                                        <input type="text" value=""/>
                                </div>

                                <div class="filter-item">
                                        <label>Type</label>
                                        <select multiple="multiple"><option>All records</option><option>Only publicated</option><option>Only deleted</option></select>
                                </div>

                                <div class="filter-item">
                                        <label>Publication date</label>
                                        From: <input class="date-input" type="text" />
                                        To: <input class="date-input" type="text" />
                                </div>

                                <div class="cl">
                                        <input type="button" class="btn filter-send" value="Filter results" /> <a class="filter-reset-button" href="" title="Reset filters">Reset filters</a> | <a class="filter-button" href="" title="Hide filters">Hide filters</a>
                                </div>

                        </form>

                </div>

                <table class="table-a" summary="Table">
                        <thead>
                                <tr>
                                        <th scope="col" class="chb"><input class="chall" type="checkbox" /></th>
                                        <th scope="col">ID</th>
                                        <th scope="col">Nazwa</th>
                                        <th scope="col">Nazwa tła obrazka</th>
                                        <th scope="col" style="width: 65px;">Operacja</th>
                                </tr>
                        </thead>

                        <tbody>
                            <?php foreach ($categories as $d): ?>
                                <tr>
                                        <td><input type="checkbox" /></td>
                                        <td><?php echo $d['id']; ?></td>
                                        <td><?php echo $d['name']; ?></td>
                                        <td><?php echo $d['img']; ?></td>
                                       
                                        <td>
                                                <a href="index.php?controller=demot&action=edit_category&id=<?php echo $d['id']; ?>" class="table-icon edit" title="Edit"></a>
                                                <a href="index.php?controller=demot&action=delete_category&id=<?php echo $d['id']; ?>" class="table-icon delete" title="Delete"></a>
                                                <a href="index.php?controller=demot&action=delete" class="table-icon download" title="Download"></a>
                                        </td>
                                </tr>
                            <?php endforeach; ?>
                                
                        </tbody>
                </table>              

        </div>

</div>


<div class="round half right">
    <div class="round-head">
            <h2>Dodaj/Edytuj nową kategorię</h2>                
    </div>

    <div class="round-content">        
        <form action="<?php echo $action; ?>" method="POST">
            Nazwa kategorii:<br/>
            <input type="hidden" name="data[id]" value="<?php echo $demot_category['id']; ?>"/> 
            <input type="text" name="data[name]" value="<?php echo $demot_category['name']; ?>"/>
            <br/>
            Nazwa obrazka<br/>
            <input type="text" name="data[img]" value="<?php echo $demot_category['img']; ?>"/>
            <div class="cl" style="background: #e2e2e2; margin-top: 10px; padding: 10px; ">
                <input type="submit" class="btn" value="Zapisz/Edytuj kategorie" />                
            </div> 
        </form>        
    </div>
    
</div>